<ul class = "ynadvsearch_searchresult">
<?php if($this->noSearchQuery): ?>
<li>
  <div class="tip">
    <span>
      <?php echo $this->translate('Please enter a search query.') ?>
    </span>
  </div>
  </li>
<?php elseif( $this->noResult): ?>
  <li>
  <div class="tip">
    <span>
      <?php echo $this->translate('No results were found.') ?>
    </span>
  </div>
  </li>
<?php else: ?>


   <?php 
   if ($this->mod && $this->mod != '') {
   		$mod = $this->mod;
   }
   else {
   		$mod = '';
   }
   $searchModuleTable = new Ynadvsearch_Model_DbTable_Modules;
   foreach( $this->results as $module => $res ): 
   ?>
   <li>
   <div class="search_results" id = "result_<?php echo $module?>">
   <?php 
  	 if ($mod != $module) :
    	$mod = $module; ?>	
    	<div class="search_type">
    		<?php 
    		$title = $searchModuleTable->getModuleTitleByName($module);
    		echo $this->translate(strtoupper($title));?>
    	</div>
   <?php endif; 
   $count = 0;
   foreach ($res as $item) :
   $count++;
   if ($count == 11) {
   	continue;
   }
   $item = $this->item($item->type, $item->id);
    if( !$item ) continue; 
    
    ?> 
    <div class="search_result">
      <div class="search_photo">
        <?php echo $this->htmlLink($item->getHref(), $this->itemPhoto($item, 'thumb.icon')) ?>
      </div>
      <div class="search_info">
        <?php if( '' != $this->query ): ?>
          <?php echo $this->htmlLink($item->getHref(), $this->highlightText($item->getTitle(), $this->query), array('class' => 'search_title')) ?>
        <?php else: ?>
          <?php echo $this->htmlLink($item->getHref(), $item->getTitle(), array('class' => 'search_title')) ?>
        <?php endif; ?>
        <p class="search_description">
          <?php if( $module != "news" ): ?>
	          <?php if( '' != $this->query ): ?>
	            <?php echo $this->highlightText($this->viewMore($item->getDescription()), $this->query); ?>
	          <?php else: ?>
	            <?php echo $this->viewMore($item->getDescription()); ?>
	          <?php endif; ?>
          <?php endif; ?>
        </p>
      </div>
       </div>
    <?php endforeach;?>
    <?php if ($count > $this->limit) : ?>
	    <div class = "show_more_result" id = "<?php echo $module?>_show_more_result_<?php echo $this->from?>"> 
	  	<a href='javascript:void(0);' onclick="showMore('<?php echo $module?>','<?php echo $this->from?>')"><?php echo $this->translate('Show More Results')?></a>
		</div>
		<div class="show_more_result" id="<?php echo $module?>_result_loading_<?php echo $this->from?>" style="display: none;">
		  <img src='<?php echo $this->layout()->staticBaseUrl ?>application/modules/Core/externals/images/loading.gif' style='float:left;margin-right: 5px;' />
		  <?php echo $this->translate("Loading ...") ?>
		</div>
<?php endif;?>
 </div>
</li>
  <?php endforeach; ?>
  <?php endif; ?>
</ul>
<script type="text/javascript">
function showMore(module,from){
	var url = '<?php echo $this->url(array('module' => 'core','controller' => 'widget','action' => 'index','content_id' => $this->identity), 'default', true) ?>';
    $(module + '_show_more_result_' + from).style.display = 'none';
    $(module + '_result_loading_' + from).style.display = '';
	var limit = '<?php echo $this->limit?>';
	limit = parseInt(limit);
	from = parseInt(from);
	var value = limit + from;
    var request = new Request.HTML({
      url : url,
      data : {
        format : 'html',
        'phrase' : '<?php echo $this->query?>',
        'search' : module,
        'from' : value,
        'type' : 'ajax'
      },
      onSuccess : function(responseTree, responseElements, responseHTML, responseJavaScript) {
          Elements.from(responseHTML).inject($("result_" + module));
        $(module + '_result_loading_' + from).setStyle('display','none');
        }
    });
   request.send();
  }

</script>
